# Contributor: Valery Kartel <valery.kartel@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=xfsprogs
pkgver=5.18.0
pkgrel=0
pkgdesc="XFS filesystem utilities"
url="https://xfs.org/index.php/Main_Page"
arch="all"
license="LGPL-2.1-or-later"
makedepends="
	attr-dev
	bash
	gzip
	inih-dev
	linux-headers
	python3
	userspace-rcu-dev
	util-linux-dev
	"
options="!check"  # no test suite
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs $pkgname-extra"
source="https://www.kernel.org/pub/linux/utils/fs/xfs/xfsprogs/xfsprogs-$pkgver.tar.gz
	fix-mmap.patch
	missing-signal.h.patch
	"

build() {
	export DEBUG=-DNDEBUG
	export OPTIMIZER="$CFLAGS"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sbindir=/sbin \
		--libexecdir=/usr/lib \
		--enable-gettext=no
	make SHELL=/bin/bash
}

package() {
	make -j1 DIST_ROOT="$pkgdir" install install-dev
	find "$pkgdir" -name *.la -delete
	mv "$pkgdir"/sbin "$pkgdir"/usr
	mkdir -p "$pkgdir"/sbin
	for i in mkfs.xfs fsck.xfs xfs_repair; do
		mv "$pkgdir"/usr/sbin/$i "$pkgdir"/sbin/
	done
	chown -R root:root "$pkgdir"/*
}

extra() {
	depends="$pkgname python3" # python3 for xfs_scrub_all
	pkgdesc="XFS filesystem extra utilities"
	mkdir -p "$subpkgdir"
	rm -rf "$pkgdir"/lib "$pkgdir"/usr/lib
	mv "$pkgdir"/usr "$subpkgdir"/
}

sha512sums="
5bd3ec269d5685a5215fd414ae36d41ba33ddbbe5a22e8b3ccb080629495fb156271754877260f4acde4b7df496049fe1a341ebad126c071a87d74dbf410e4f6  xfsprogs-5.18.0.tar.gz
080161b211e20277e44f714961b36064536bb5cce72a6f93fef4996e296a3953d33c1a066ef371ccd5551622357105f9be9086ef917386f5d43f6a211b0bd7c9  fix-mmap.patch
3dc132c45d93eeefe06ad3d53c39f325f4b003e3a230d5961599f7dac2026360ff57820be351b945385bfe1d6669cb182706696f59ae8d23f7c73dd7fe8d092a  missing-signal.h.patch
"
